package hc.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class Markdown {
	static public String generateHtml(File mdFile) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(mdFile), "UTF-8"));
		String line = null;
		String mdContent = "";
		while ((line = br.readLine()) != null) {
			mdContent += line + "\r\n";
		}
		
		org.pegdown.PegDownProcessor pdp = new org.pegdown.PegDownProcessor(Integer.MAX_VALUE);
		String htmlContent = pdp.markdownToHtml(mdContent);
		
		br.close();
		return htmlContent;
	}
	
	public static void main(String[] args) throws IOException {
		String md =  generateHtml(new File("C:/WD/workspace0409/BusinessRuleEngine/src/main/resources/static/docs/quickstart.md"));
		System.out.println(md);
	}

}
